// // Copyright (c) 2009 All Right Reserved // // vl // // 2009-01-01 // Contains ... using System.Diagnostics.Contracts; using System.Globalization; using System.Text; using System.Xml.Linq; using JetBrains.Annotations; using LargoCommon.Localization; namespace LargoCommon.Music { /// /// Loudness Change. /// public sealed class LoudnessChange : AbstractChange { #region Constructors /// /// Initializes a new instance of the class. /// [UsedImplicitly] public LoudnessChange() { } /// /// Initializes a new instance of the class. /// /// The given change. public LoudnessChange(XElement xchange) : base(xchange) { Contract.Requires(xchange != null); //// if (xchange == null) { return; } this.LoudnessBase = DataEnums.ReadAttributeMusicalLoudness(xchange.Attribute("MusicalLoudness")); ////201509!!!!! this.LoudnessBase = (MusicalLoudness)LibSupport.ReadByteAttribute(xchange.Attribute("LoudnessBase")); //// this.LoudnessBase = MusicalLoudness.MeanLoudness; this.ChangeType = MusicalChangeType.Loudness; } /// /// Initializes a new instance of the class. /// /// The given bar. /// The given line. /// The given loudness. public LoudnessChange(int givenBar, int givenLine, MusicalLoudness givenLoudness) : base(givenBar, givenLine, MusicalChangeType.Loudness) { this.LoudnessBase = givenLoudness; } /// /// Initializes a new instance of the class. /// /// The given bar. /// The given line. public LoudnessChange(int givenBar, int givenLine) : base(givenBar, givenLine, MusicalChangeType.Loudness) { } #endregion #region Properties - Xml /// /// Gets Xml representation. /// /// /// Property description. /// public override XElement GetXElement { get { var change = base.GetXElement; change.Add(new XAttribute("LoudnessBase", this.LoudnessBase)); return change; } } #endregion #region Properties /// Gets or sets class of melodic part. /// Property description. public MusicalLoudness LoudnessBase { get; set; } /// /// Gets LoudnessBaseString. /// /// Property description. //// Do not make private!!! - It is used by DetailMusicalChanges.xaml. [UsedImplicitly] public string LoudnessBaseString => LocalizedMusic.String("Loud" + ((byte)this.LoudnessBase).ToString(CultureInfo.CurrentCulture)); #endregion #region Public methods /// /// Clones this instance. /// /// Returns object. public override object Clone() { var tmc = new LoudnessChange(this.BarNumber, this.LineIndex) { LoudnessBase = this.LoudnessBase }; //// tmc.BlockModel = this.BlockModel; return tmc; } #endregion #region String representation /// String representation of the object. /// Returns value. public override string ToString() { var s = new StringBuilder(); s.AppendFormat(CultureInfo.CurrentCulture, base.ToString()); s.Append(", " + this.LoudnessBaseString); return s.ToString(); } #endregion } }